package com.util;

import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.GoodsInfoDAO;
import com.entity.PageModel;

public class PublicToolShowGoodsInfolist {

	public static void searchGoodsInfo(HttpServletRequest request,
			HttpServletResponse response, String cp, String key) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();

		int sumCount = gdao.getSearchSumGoodsCount(key);

		PageModel pm = PublicToolPageModel
				.getPageInfo(request, sumCount, cp);

		ArrayList<Object> goodsInfoList = gdao.searchProductPageModel(pm, key);
		request.setAttribute("goodsInfoList", goodsInfoList);
	}

	// 前台用显示搜索列表
	public static void searchGoodsInfoweb(HttpServletRequest request,
			HttpServletResponse response, String cp, String key, String order) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();

		int sumCount = gdao.getSearchSumGoodsCount(key);

		PageModel pm = PublicToolPageModel
				.getPageInfo(request, sumCount,cp);

		ArrayList<Object> goodsInfoList = gdao.searchProductPageModelweb(pm,
				key, order);
		request.setAttribute("goodsInfoList", goodsInfoList);
	}

	/**
	 * 前台用显示分类列表
	 * @param request
	 * @param response
	 * @param cp
	 * @param typeid
	 * @param order
	 */
	public static void typelistGoodsInfoweb(HttpServletRequest request,
			HttpServletResponse response, String cp, String typeid, String order) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();
		int sumCount = gdao.gettypelistGoodsCount(typeid);
		PageModel pm = PublicToolPageModel.getPageInfo(request, sumCount,cp);
		ArrayList<Object> goodsInfoList = gdao.typelistProductPageModelweb(pm,typeid, order);
		request.setAttribute("goodsInfoList", goodsInfoList);
	}

	public static void showGoodsInfoList(HttpServletRequest request,
			HttpServletResponse response, String cp) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();

		int sumCount = gdao.getSumGoodsCount();

		PageModel pm = PublicToolPageModel
				.getPageInfo(request, sumCount, cp);

		ArrayList<Object> goodsInfoList = gdao.getPageModelOfAllGoods(pm);
		request.setAttribute("goodsInfoList", goodsInfoList);

	}

	public static void searchGoodsInfoforthirdId(HttpServletRequest request,
			HttpServletResponse response, String cp, String key, String thirdId) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();

		int sumCount = gdao.getSearchSumGoodsCountforthirdId(key, thirdId);

		PageModel pm = PublicToolPageModel
				.getPageInfo(request, sumCount,cp);

		ArrayList<Object> goodsInfoList = gdao
				.searchProductPageModelforthirdId(pm, key, thirdId);
		request.setAttribute("goodsInfoList", goodsInfoList);
	}
	/**
	 * 坐诊信息管理列表
	 * @param request
	 * @param response
	 * @param cp
	 * @param thirdId
	 */
	public static void showGoodsInfoListforthirdId(HttpServletRequest request,
			HttpServletResponse response, String cp, String thirdId) {

		GoodsInfoDAO gdao = new GoodsInfoDAO();

		int sumCount = gdao.getSumGoodsCountforthirdId(thirdId);

		PageModel pm = PublicToolPageModel.getPageInfo(request, sumCount,cp);

		ArrayList<Object> goodsInfoList = gdao.getPageModelOfAllGoodsforthirdId(pm, thirdId);
		request.setAttribute("goodsInfoList", goodsInfoList);
	}

}
